#pragma once

#include <cstdint>

namespace sirtet
{

struct Color final
{
  private:
    union {
        uint8_t rgba[4];
        uint32_t color_code;
    } val;

  public:
    Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
    {
        get_red_mut() = r;
        get_green_mut() = g;
        get_blue_mut() = b;
        get_alpha_mut() = a;
    }

    Color(uint32_t color_code)
    {
        val.color_code = color_code;
    }

    uint8_t &get_red_mut()
    {
        return val.rgba[3];
    }
    uint8_t get_red()
    {
        return uint8_t(get_red_mut());
    }

    uint8_t &get_green_mut()
    {
        return val.rgba[2];
    }
    uint8_t get_green()
    {
        return uint8_t(get_green_mut());
    }

    uint8_t &get_blue_mut()
    {
        return val.rgba[1];
    }
    uint8_t get_blue()
    {
        return uint8_t(get_blue_mut());
    }

    uint8_t &get_alpha_mut()
    {
        return val.rgba[0];
    }
    uint8_t get_alpha()
    {
        return uint8_t(get_alpha_mut());
    }

    uint32_t &get_color_code_mut()
    {
        return val.color_code;
    }
    uint32_t get_color_code()
    {
        return uint32_t(val.color_code);
    }
};

} // namespace sirtet